#ifndef _PHYSICS_LAYER_H_
#define _PHYSICS_LAYER_H_

#include "cocos2d.h"
#include "Box2D/Box2D.h"
#include "GLES-Render.h"
#include "TopographyManager.h"
#include "Player.h"
#include "ContactListener.h"
#include "BackgroundLayer.h"
#include "GameLayerManager.h"

USING_NS_CC;

class PhysicsLayer : public CCLayer, public PlayerEventListener
{
  public:
    virtual ~PhysicsLayer();
    static PhysicsLayer * create();
    bool init();
    void draw();
    virtual void update(float dt);
    void setBackgroundLayer(BackgroundLayer * pBackgroundLayer);
    void setGameLayerManager(GameLayerManager * pGameLayerManager);

    bool ccTouchBegan(CCTouch * pTouch, CCEvent * pEvent);
    void ccTouchEnded(CCTouch * pTouch, CCEvent * pEvent);
    void onPlayerDead();
    void setPropCount(int count);
    void restart();
  private:
    PhysicsLayer();
    static b2World* pWorld;
    GLESDebugDraw debugDraw;
    BackgroundLayer * pBackgroundLayer;
    GameLayerManager * pGameLayerManager;
    Player * pPlayer;
    TopographyManager topographyManager;
    ContactListener contactListener;

  private:
    void createWorld();
};

#endif
